package leetCode;

public class t349 {
    public static void main(String[] args) {

    }
}
class Solutiont349 {
    public int[] intersection(int[] nums1, int[] nums2) {
        int nums[]=new int[1000];
        int nums22[]=new int[1000];
        for (int i =0;i<nums1.length;i++){
            if (nums[nums1[i]]==0){
                nums[nums1[i]]++;
            }
        }
        for (int i =0;i<nums2.length;i++){
            if (nums22[nums2[i]]==0){
                nums22[nums2[i]]++;
            }
        }
        for (int i =0;i<nums.length;i++){
            nums[i]=nums[i]+nums22[i];
        }
        int length=0;

        for (int i=0;i<1000;i++){
            if (nums[i]>1){
                length++;
            }
        }
        int ret[]=new int[length];
        int index=0;
        for (int i=0;i<1000;i++){
            if (nums[i]>1){
                ret[index]=i;
                index++;
            }
        }
        return ret;
    }
}
